﻿#include "subscriber.h"
#include "sessionmanager.h"
#include <functional>
#include <algorithm>

void SessionManager::join(Subscriber* subscriber)
{
	_subscribers.insert(subscriber);
}

void SessionManager::leave(Subscriber* subscriber)
{
	_subscribers.erase(subscriber);
}

void SessionManager::broadcast(const char *msg, int len)
{
    for (auto& subscriber : _subscribers)
    {
        subscriber->doTcpWrite(msg, len);;
    }
}
